package part1;

/**
 * <p>Title: Project 10 part 1</p>
 * <p>Description: CS 235 Project #10 pt. 1
 *       Shows how to get started with setting up Preconditions and postconditions.</p>
 *       
 * Part1 class is a client of the Piece class
 * 
 * @author Anthony Varghese
 * @date   February 5th 2012
 * @version 1.0
 */

public class Part1 {
	private static java.io.PrintStream out = System.out;
	
	/**
	 * main - main method for Part2 program<br/>
	 * Sets up two Piece objects in a game
	 * and moves them around.
	 * 
	 * @param args
	 * @throws InterruptedException 
	 */
	public static void main(String[] args) throws InterruptedException {
		out.println( "New Game" );
		
		Piece explorer = new Piece( 10, 20 );
		Piece snake    = new Piece( 50, 40 );
		
		out.println("   Explorer starting at position: " + explorer.getXposition() + ", " + explorer.getYposition() );
		out.println("   Snake  starting  at  position: " + snake.getXposition() + ", " + snake.getYposition() +"\n");

		// Wait and then move.
		out.println("  Explorer moving ... ");
		Thread.sleep( 1000 /* milliseconds */ );
		
		explorer.move( 5, 5 );
		out.println("    Explorer is now at position: " + explorer.getXposition() + ", " + explorer.getYposition() +"\n");

		// Wait and then move.
		out.println("  Snake moving ... ");
		Thread.sleep( 1000 /* milliseconds */ );

		snake.move( -10, -10 );
		out.println("    Snake  is  now at  position: " + snake.getXposition() + ", " + snake.getYposition() +"\n");

		// Wait
		Thread.sleep( 1000 /* milliseconds */ );

		double distance = explorer.distance( snake );
		if ( distance < 1)
			explorer.die();
		else {
			// call the compute method to roughly how far in the y direction to move
			double ydist = explorer.compute( distance, explorer.getXposition()-snake.getXposition() );
		}
		
		// Report which pieces are alive
		out.println("Explorer is " + ( explorer.isAlive() ? "alive." : "not alive."));
		out.println("Snake   is  " + ( snake.isAlive()    ? "alive." : "not alive.") +"\n");
		out.println("Game over!");
	}
}